// 获取submit按钮
let form = layui.form
let layer = layui.layer

$('.layui-form').on('submit', function (e) {
    e.preventDefault()
    // 2,收集数据
    let data = $(this).serialize()
    // 3,提交
    $.ajax({
        url: '/api/login',
        type: 'post',
        data: data,
        success: function (res) {
            if (res.status === 0) {
                localStorage.setItem('token', res.token)
                location.href = './index.html'
            } else {
                layer.msg(res.message)
            }
        }
    })
})